package metier;

import junit.framework.*;

public class TacheTest extends TestCase {
	
	public void testGet() {
		Tache maTache = new Tache(1,"Cowcow",2,3,4);
		assertEquals(maTache.getNumTache(),1);
		assertEquals(maTache.getLibelle(),"Cowcow");
		assertEquals(maTache.getChargePreviJoursHomme(),2);
		assertEquals(maTache.getMatriculeCollaborateur(),3);
		assertEquals(maTache.getReferenceContrat(),4);
	}
	
	public void testSetLibelle() {
		Tache maTache = new Tache(1,"Cowcow",2,3,4);
		maTache.setLibelle("Coucou");
		assertEquals(maTache.getLibelle(),"Coucou");
		maTache.setLibelle("");
		assertEquals(maTache.getLibelle(),"");
		maTache.setLibelle("Cou8u");
		assertEquals(maTache.getLibelle(),"Cou8u");
	}
	
	public void testSetChargePreviJoursHommePrenom() {
		Tache maTache = new Tache(1,"Cowcow",2,3,4);
		maTache.setChargePreviJoursHommePrenom(99);
		assertEquals(maTache.getChargePreviJoursHomme(),99);
		maTache.setChargePreviJoursHommePrenom(0);
		assertEquals(maTache.getChargePreviJoursHomme(),0);
		maTache.setChargePreviJoursHommePrenom(-99);
		assertEquals(maTache.getChargePreviJoursHomme(),-99);
	}
	
	public void testSetMatriculeCollaborateur() {
		Tache maTache = new Tache(1,"Cowcow",2,3,4);
		maTache.setMatriculeCollaborateurm(99);
		assertEquals(maTache.getMatriculeCollaborateur(),99);
		maTache.setMatriculeCollaborateurm(0);
		assertEquals(maTache.getMatriculeCollaborateur(),0);
		maTache.setMatriculeCollaborateurm(-99);
		assertEquals(maTache.getMatriculeCollaborateur(),-99);
	}
	
	public void testSetReferenceContrat() {
		Tache maTache = new Tache(1,"Cowcow",2,3,4);
		maTache.setReferenceContrat(99);
		assertEquals(maTache.getReferenceContrat(),99);
		maTache.setReferenceContrat(0);
		assertEquals(maTache.getReferenceContrat(),0);
		maTache.setReferenceContrat(-99);
		assertEquals(maTache.getReferenceContrat(),-99);
	}
	
	public void testEquals() {
		Tache maTache1 = new Tache(1,"Cowcow",2,3,4);
		Tache maTache2 = new Tache(2,"Cowcow",3,2,1);
		assertEquals(maTache1.Equals(maTache2),false);
		assertEquals(maTache2.Equals(maTache1),false);
		assertEquals(maTache1.Equals(maTache1),true);
		assertEquals(maTache2.Equals(maTache2),true);
		
		Tache maTache3 = new Tache(8,"Parfaitement �gales",8,8,8);
		Tache maTache4 = new Tache(8,"Parfaitement �gales",8,8,8);
		assertEquals(maTache3.Equals(maTache4),true);
		assertEquals(maTache4.Equals(maTache3),true);
		assertEquals(maTache3.Equals(maTache3),true);
		assertEquals(maTache4.Equals(maTache4),true);
	}
	
	public void testToStringTest() {
		Tache maTache1 = new Tache(1,"Coucou",2,3,4);
		Tache maTache2 = new Tache(2,"Cowcow",3,2,1);
		assertEquals(maTache1.toString(),"1 Coucou 2 3 4");
		assertEquals(maTache2.toString(),"2 Cowcow 3 2 1");
	}
	
	public void testToStringDescriptifTest() {
		Tache maTache1 = new Tache(1,"Coucou",2,3,4);
		Tache maTache2 = new Tache(2,"Cowcow",3,2,1);
		assertEquals(maTache1.toStringDescriptif(), "numero : 1\nlibelle :Coucou\n charge previsionnelle jours homme : 2\nmatricule collaborateur : 3\nreference contrat : 4");
		assertEquals(maTache2.toStringDescriptif(), "numero : 2\nlibelle :Cowcow\n charge previsionnelle jours homme : 3\nmatricule collaborateur : 2\nreference contrat : 1");
	}
	
}
